{% extends 'TopxiaAdminBundle::layout.html.twig' %}

{% set menu = 'admin_course_data' %}

{% set script_controller = 'course/data' %}

{% block main %}
  {% include 'TopxiaAdminBundle:Course:tab-data.html.twig' %}

    <form id="message-search-form" class="form-inline well well-sm mtl" action="" method="get" novalidate>
      {% include 'OrgBundle:Org:org-tree-select.html.twig' with {orgCode: app.request.get('orgCode'), modal: 'list'} %}
      
      <div class="form-group">
        <select style="width:150px;" class="form-control" name="categoryId">
          {{ select_options(category_choices('course'), app.request.query.get('categoryId'), '课程分类') }}
        </select>
      </div>
      <div class="form-group">
        <input class="form-control" type="text" placeholder="标题" name="title" value="{{ app.request.get('title') }}">
      </div>
      <div class="form-group">
        <input class="form-control" type="text" placeholder="创建者" name="creator" value="{{ app.request.get('creator') }}">
      </div>
      <button class="btn btn-primary">搜索</button>
    </form>
    <div class="table-responsive">
        <table class="table table-bordered" style="word-break:break-all;text-align:center;">
          <tr class="active">
            <td width="30%">课程名</td>
             {% if filter == 'classroom' %}
            <td>所在{{setting("classroom.name")|default("班级")}}</td>
             {% endif %}
            <td>课时数</td>
            <td>{% if setting('default.user_name') %}{{setting('default.user_name')|default('学员')}}{% else %}学员{% endif %}人数</td>
            <td>完成课程人数</td>
            <td>课程学习时长(分)</td>
            <td>课程收入(元)</td>
            <td>操作</td>
          </tr>
          
          {% if courses %}
            {% for course in courses %}
            <tr>
            <td><a data-toggle="modal" data-target="#modal" data-url="{{path('course_detail_data',{id:course.id})}}" href="javascript:">{{course.title}}</a></td>
            {% if filter == 'classroom' %}
            <td>
            {% set classroom = classrooms[course.id]|default(null) %}
            {% if classroom %}
            <a href="{{path('classroom_show',{id:classroom.classroomId})}}" target="_blank">{{classroom.classroomTitle}}</a>
            {% elseif not classroom %}
            <span class="label label-danger live-label mls">未引用</span> 
            {% endif %}
            </td>
            {% endif %}
            <td>{{course.lessonCount}}</td>
            <td>{{course.studentNum}}</td>
            <td>{{course.isLearnedNum}}</td>
            <td>{{(course.learnTime/60)|round(0, 'floor')}}</td>
            <td>{{course.income}}</td>
            <td><a href="{{path('admin_course_lesson_data',{id:course.id})}}">查看课时数据</a></td>
            </tr>
            {% endfor %}
          {% endif %}
          
         
        </table>
     {{ web_macro.paginator(paginator) }}
      </div>


{% endblock %}